package com.approval.dto;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 流程验证结果
 */
@Data
public class ProcessValidationResult {
    
    /**
     * 是否有效
     */
    private Boolean valid;
    
    /**
     * 验证消息
     */
    private String message;
    
    /**
     * 错误列表
     */
    private List<String> errors;
    
    /**
     * 警告列表
     */
    private List<String> warnings;
    
    public ProcessValidationResult() {
        this.errors = new ArrayList<>();
        this.warnings = new ArrayList<>();
    }
    
    public static ProcessValidationResult success(String message) {
        ProcessValidationResult result = new ProcessValidationResult();
        result.setValid(true);
        result.setMessage(message);
        return result;
    }
    
    public static ProcessValidationResult failure(String message) {
        ProcessValidationResult result = new ProcessValidationResult();
        result.setValid(false);
        result.setMessage(message);
        return result;
    }
    
    public void addError(String error) {
        this.errors.add(error);
    }
    
    public void addWarning(String warning) {
        this.warnings.add(warning);
    }
    
    public boolean hasErrors() {
        return !this.errors.isEmpty();
    }
    
    public boolean hasWarnings() {
        return !this.warnings.isEmpty();
    }
}

